<template>
	<view class="content">
		<!-- 父传子方式同vue语法一样，通过props传递 -->
			<test :msg="title" @testclick = "testEvent"></test>
			<test2></test2>
	</view>
</template>

<script>
	import test2 from "../../components/test2.vue"
	import test from "../../components/test.vue"
	
	export default {
		data() {
			return {
				title: 'news'
			}
		},
		components:{
			test,test2
		},
		onLoad() {
			// 通过uni对象实现内部监听绑定。获取组件内数据，子传父
			uni.$on("testEmit",(rel)=>{
				console.log(rel)
			})
		},
		methods: {
			// vue方式实现内部监听绑定。
			testEvent(p){
				console.log(p)
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
